{% load venclave_tags %}

<table id="video-list">
  <tr>
    <th>{{ kind|title_column_name }}</th>
    {# TODO(rnk): Hardcoding these content kinds is crappy. #}
    {% ifequal kind "mo" %}
      <th class="length-col">Length</th>
    {% endifequal %}
    <th class="size-col">Size</th>
    {# TODO(rnk): Should make these headers sortable. #}
    {# TODO(rnk): Icons might be nice here. #}
    <th class="rating-col">IMDB</th>
    <th class="rating-col">MC</th>
    <th class="rating-col">RT</th>
  </tr>

  {% for node in nodes %}
    {% with node.metadata.imdb as imdb %}
      {% with node.metadata.rotten_tomatoes as rt %}
        {% with node.metadata.metacritic as mc %}
          <tr>
            <td class="item-title">
              <a href="{{ node|content_url }}">{{ node.title }}</a></td>

            {% ifequal kind "mo" %}
              <td class="item-length">
                {% if imdb.length %}{{imdb.length}} min{% else %}-{% endif %}
              </td>
            {% endifequal %}

            <td class="item-size">{{node.size|filesizeformat}}</td>
            <td class="item-rating">
              {% if imdb %}
                <a href="{{ imdb.imdb_uri }}">{{ imdb.rating|rating }}</a>
              {% endif %}
            </td>
            <td class="item-rating">
              {% if mc %}
                <a href="{{ mc.mc_uri }}">{{ mc.score|rating }}</a>
              {% endif %}
            </td>
            <td class="item-rating">
              {% if rt %}
                <a href="{{ rt.rt_uri }}">{{ rt.percent|rating }}</a>
              {% endif %}
            </td>
          </tr>
        {% endwith %}
      {% endwith %}
    {% endwith %}
  {% endfor %}

</table>
